package src.array;

import java.util.Scanner;

public class kama_no58 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        int[] arr = new int[n];
        int[] p = new int[n];    //记录前缀和的数组

        int sum = 0;
        for (int i = 0; i < n; i++) {
            arr[i] = scanner.nextInt();
            sum += arr[i];
            p[i] = sum;
        }

        int result = 0;
        while (scanner.hasNext()) {
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            if(a==0){
                result = p[b];
            }else {
                result = p[b] - p[a-1];
            }
            System.out.println(result);
        }

        scanner.close();
    }
}
